home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2000 July / macformat-092.iso / Fireworks 3 / Settings / HTML Code / Generic / slices.htt < prev   
Encoding:
Text File  |  1999-11-19  |  31.6 KB  |  1,043 lines

  1. // Fireworks Generic HTML & JavaScript.
  2. // Version 3.0 03SEP99
  3.  
  4. // To export HTML without comments change the value of variable doComments to "false".
  5. var doComments=true;
  6. var indentNestedImagemaps=false;
  7.  
  8. // When doComments is set to "true" the WRITE_HTML_COMMENT and WRITE_JS_COMMENT functions
  9. // include HTML and JavaScript comments in the exported file.
  10. function WRITE_HTML_COMMENT(str) {
  11.     if (doComments) WRITE_HTML("<!--"+str+"-->\n");
  12. }
  13.  
  14. function WRITE_JS_COMMENT(str) {
  15.     if (doComments) WRITE_HTML("/* "+str+" */\n");
  16. }
  17.  
  18. var doHeader = true;
  19. doHeader = exportDoc.generateHeader; 
  20. // When HTML is generated to a file, generateHeader is true.
  21. // When HTML is generated for the clipboard, 
  22. // generateHeader is false.
  23.  
  24.                     
  25. // These are the suffixes for the first 4 frames
  26. var sfx = new Array();
  27. sfx[0] = "";        // first frame doesn't normally have a suffix.
  28. sfx[1] = "_f2";        // second frame.
  29. sfx[2] = "_f3";        // third frame.
  30. sfx[3] = "_f4";        // fourth frame.
  31. var numSFX = 4;
  32. function UpdateFileNames(curSlices) {
  33.     for (var curRow = 0; curRow < curSlices.numRows; curRow++) {
  34.         for (var curCol = 0; curCol < curSlices.numColumns; curCol++) {
  35.             if (curSlices[curRow][curCol].skipCell) continue;
  36.             var nestedTable = curSlices[curRow][curCol].nestedTableSlices;
  37.             if (nestedTable) {
  38.                 UpdateFileNames(nestedTable);
  39.                 continue;
  40.             }
  41.             var curSlice = curSlices[curRow][curCol];
  42.             var cellName = "";
  43.             if (curSlice && curSlice.getFrameFileName(0)) {
  44.                 cellName = curSlice.getFrameFileName(0).toString();
  45.                 var i;
  46.                 var limit = exportDoc.numFrames;
  47.                 if (limit > numSFX) limit = numSFX;
  48.                 for (i=0; i<limit; i++) {
  49.                     if (curSlice.getFrameFileName(i)) {
  50.                         curSlice.setFrameFileName(i, cellName + sfx[i]);
  51.                     }
  52.                 }
  53.             }
  54.         }
  55.     }
  56. }
  57. UpdateFileNames(slices);
  58.  
  59. var d = new Date();
  60. if (doHeader) {
  61.     // Write general comments for copying and pasting Fireworks-generated code into existing HTML documents.
  62.     WRITE_HTML_COMMENT("To put this html into an existing HTML document, you must copy the JavaScript and");
  63.     WRITE_HTML_COMMENT("paste it in a specific location within the destination HTML document. You must then copy");
  64.     WRITE_HTML_COMMENT("and paste the table in a different location.");
  65.     WRITE_HTML("\n");
  66.  
  67.  
  68.     WRITE_HTML("<html>\n");
  69.     WRITE_HTML("\n");
  70.  
  71.     WRITE_HTML("<head>\n");
  72.     WRITE_HTML("\n");
  73.  
  74.     // Use Base Name from export dialog as document title.
  75.     WRITE_HTML("<title>", exportDoc.filename, "</title>\n");
  76.     WRITE_HTML("\n");
  77.  
  78.     // Write Meta tags.
  79.     WRITE_HTML("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=");
  80.     var charSet = App.getPref("HtmlCharSet");
  81.     if (charSet == "") charSet = "iso-8859-1";
  82.     WRITE_HTML(charSet + "\">\n"); 
  83.     WRITE_HTML("<meta name=\"description\" content=\"Fireworks Splice HTML\">\n");
  84.     WRITE_HTML("\n");
  85.  
  86. }
  87. // Write HTML target and date created.
  88. WRITE_HTML("<!-- Fireworks 3.0 Generic target.\n    Created ", d, " -->\n");
  89. WRITE_HTML("\n");
  90.  
  91. // Declare variables for processing Behaviors.    
  92. var kActionStatusMessage = 1;
  93. var kActionSwapImage = 2;
  94. var kActionButtonDown = 4;
  95. var kActionSwapImageRestore = 5;
  96. var kActionButtonHighlight = 6; 
  97. var kActionButtonRestore = 7;
  98.  
  99.  
  100. var kEventMouseOver = 0;
  101. var kEventOnClick = 1;
  102. var kEventMouseOut = 2;
  103. var kEventOnLoad = 3;
  104.  
  105. var hasStatusMessage = false;
  106. var hasSwap = false;
  107. var hasDown = false;
  108. var hasRestore = false;
  109. var hasOnloadInits = false;
  110.  
  111. // Function cellName determines the name for the image in a particular table cel
  112. // cellName is based off of the slice name if one was specified. Otherwise the
  113. // Base file name from the export dialog is used.
  114. function CellName(curSlices, row, col) {
  115.     var curSlice = curSlices[row][col];
  116.     var cellName = "";
  117.     if (curSlice && curSlice.getFrameFileName(0)) {
  118.         cellName = curSlice.getFrameFileName(0).toString();
  119.         // remove illegal characters
  120.         cellName = cellName.replace(/\W/g, "");
  121.         // if it starts with a number, add N to the front.
  122.         if (cellName == "") cellName = "n" + exportDoc.imagename + "_" + (row+1) + "_" + (col+1);
  123.         if (cellName.search(/\d/) == 0) {
  124.             cellName = "n"+cellName;
  125.         }
  126.     }
  127.     if (cellName!="") return(cellName);     
  128.  
  129.     var prefix;
  130.     if (!curSlices) return("nullCellName");
  131.     if (curSlices.id == 0) {
  132.         prefix = "";
  133.     } else {
  134.         prefix = curSlices.id+"_";
  135.     }
  136.     var suffix="";
  137.     if (curSlices.numRows > 1 || curSlices.numColumns > 1) {
  138.         suffix = "_" + (row+1) + "_" + (col+1);
  139.     }
  140.     cellName = "n" + prefix + exportDoc.imagename + suffix;
  141.     return(cellName);
  142. }
  143.  
  144.  
  145.  
  146. // Determine and process Behaviors in the document.
  147. function ProcessEvent(theCurBehaviors, targetEvent) {
  148.     // Declare variable for processing Behaviors.
  149.     var javaScript = "";
  150.     var stat = false;
  151.     var eraseStatOnMouseOut = false;
  152.     var swapImage = "";
  153.     var nbHighlight = "";
  154.     var nbHighlightPreload = false;
  155.     var nbDown = "";
  156.     var nbDownPreload = false;
  157.     var swap = "";
  158.     var swapRestore = false;
  159.     var buttonRestore = false;
  160.     
  161.     // Translate Behaviors into JavaScript.
  162.     for (var i=0; i<theCurBehaviors.numberOfBehaviors; i++) {
  163.         var curBehavior = theCurBehaviors[i];
  164.         
  165.         // Check for erase on mouse out status messages.
  166.         if (curBehavior.action == kActionStatusMessage) {
  167.             if (curBehavior.restoreOnMouseout) eraseStatOnMouseOut=true;
  168.         }
  169.         
  170.         if (curBehavior.event != targetEvent) continue;
  171.         
  172.         if (curBehavior.action == kActionStatusMessage) {
  173.             var statMsg = curBehavior.statusText;
  174.             var curStat = "";
  175.             curStat = "MM_displayStatusMsg('" + statMsg + "');";
  176.             javaScript += curStat;
  177.             stat = true;
  178.             continue;
  179.         }
  180.         if (curBehavior.action == kActionSwapImageRestore) {
  181.             swapRestore = true;
  182.             continue;
  183.         }
  184.  
  185.         if (curBehavior.action == kActionButtonRestore) {
  186.             buttonRestore = true;
  187.             continue;
  188.         }
  189.                 
  190.         var swapRow = curBehavior.targetRowNum;
  191.         var swapCol = curBehavior.targetColumnNum;
  192.         var swapFrame = curBehavior.targetFrameNum; 
  193.         var swapTable = curBehavior.targetTable;
  194.         var fileName;
  195.  
  196.         if (!swapTable) {
  197.             /* Not a swap behavior, so continue. */
  198.             continue;
  199.         }
  200.         
  201.         if (curBehavior.hasHref) {
  202.             fileName = curBehavior.href;
  203.         } else {
  204.             fileName = swapTable.imagesDirPath + swapTable[swapRow][swapCol].getFrameFileName(swapFrame) + swapTable[swapRow][swapCol].imageSuffix;
  205.         }
  206.         
  207.         var cellName = CellName(swapTable, swapRow,swapCol);
  208.         
  209.         // Translate button Behaviors into JavaScript.
  210.         if (curBehavior.action == kActionButtonDown) {
  211.             //MM_nbGroup(event, groupName, imgName, downSrc...preloadMarker)
  212.             nbDown += "'" + cellName + "','" + fileName + "',";
  213.             if (curBehavior.preload) nbDownPreload = true;
  214.             continue;
  215.         }
  216.         // Translate button Behaviors into JavaScript.
  217.         if (curBehavior.action == kActionButtonHighlight) {
  218.             var highlightName = "";
  219.             if (curBehavior.downHighlight) {
  220.                 if (curBehavior.hasDhHref) {
  221.                     highlightName = curBehavior.dhHref;
  222.                 } else {
  223.                     var f = curBehavior.dhTargetFrameNum;
  224.                     highlightName = swapTable.imagesDirPath + swapTable[swapRow][swapCol].getFrameFileName(f) + swapTable[swapRow][swapCol].imageSuffix
  225.                 }
  226.             }            
  227.             nbHighlight += "'" + cellName + "','" + fileName + "','" + highlightName +"',";
  228.             if (curBehavior.preload) nbHighlightPreload = true;
  229.             continue;
  230.         }
  231.         // Translate Swap Image Behaviors into JavaScript.
  232.         if (curBehavior.action == kActionSwapImage) {
  233.             swap += "'" +cellName +"','','" + fileName + "',";
  234.             continue;
  235.         }        
  236.     }
  237.      
  238.       if (nbDown != "") {
  239.         javaScript += "MM_nbGroup('down','navbar1'," + nbDown
  240.         if (nbDownPreload) {
  241.             javaScript += "1);";
  242.         } else {
  243.             javaScript += "0);";
  244.         }
  245.     }
  246.     if (nbHighlight != "") {
  247.         javaScript += "MM_nbGroup('over'," + nbHighlight
  248.         if (nbHighlightPreload) {
  249.             javaScript += "1);";
  250.         } else {
  251.             javaScript += "0);";
  252.         }
  253.     }
  254.     if (swap != "") {
  255.         javaScript += "MM_swapImage(" + swap + "1);";
  256.     }
  257.     if (swapRestore) {
  258.         javaScript += "MM_swapImgRestore();";
  259.     }
  260.     if (buttonRestore) {
  261.         javaScript += "MM_nbGroup('out');";
  262.     }
  263.     // Erase status bar message onMouseOut.
  264.     if (eraseStatOnMouseOut && targetEvent == kEventMouseOut) {
  265.         javaScript += "MM_displayStatusMsg(' ');" ;
  266.         stat = true;
  267.     }
  268.     
  269.     if (stat) javaScript += "return document.MM_returnValue";
  270.     return(javaScript);
  271. }
  272.  
  273.  
  274. // Determine and process Behaviors in the document.
  275. function ProcessBehavior(theCurBehaviors) {
  276.     
  277.     javaOver = ProcessEvent(theCurBehaviors, kEventMouseOver);
  278.     javaOut = ProcessEvent(theCurBehaviors, kEventMouseOut);
  279.     javaClick = ProcessEvent(theCurBehaviors, kEventOnClick);
  280.     if (javaOver != "" || javaOut != "" || javaClick != "") {
  281.         return(true);
  282.     }
  283.     return(false);
  284. }
  285.  
  286. function DoFile(curBeh) {
  287.     var swapRow = curBeh.targetRowNum;
  288.     var swapCol = curBeh.targetColumnNum;
  289.     var swapFrame = curBeh.targetFrameNum; 
  290.     var swapTable = curBeh.targetTable;
  291.     var fileName = swapTable[swapRow][swapCol].getFrameFileName(0);
  292.     if (curBeh.downHighlight && curBeh.hasDhTargetFrame) {
  293.         var fm = curBeh.dhTargetFrameNum;
  294.         if (!swapTable[swapRow][swapCol].getFrameFileName(fm)) {
  295.             var tmp;
  296.             var frame = fm+1;
  297.             if (fm < 4) {
  298.                 tmp = fileName + sfx[fm];
  299.             } else {
  300.                 tmp = fileName + "_f" + frame;
  301.             }
  302.             swapTable[swapRow][swapCol].setFrameFileName(fm, tmp);
  303.         }
  304.     }
  305.     if (curBeh.preload) {
  306.         DoPreload(curBeh);
  307.     }
  308.     if (curBeh.hasTargetFrame && swapFrame > 0) {
  309.         if (!swapTable[swapRow][swapCol].getFrameFileName(swapFrame)) {
  310.             var frame = swapFrame + 1;
  311.             if (swapFrame < 4) {
  312.                 fileName = fileName + sfx[swapFrame];
  313.             } else {
  314.                 fileName = fileName + "_f" + frame;
  315.             }
  316.             swapTable[swapRow][swapCol].setFrameFileName(swapFrame, fileName);
  317.         }
  318.     } 
  319. }
  320.  
  321. var filesToPreload = new Array;
  322. var autoFrame = exportDoc.numFrames+1;
  323.  
  324. function PreloadFile(fileName, swapTable, swapRow, swapCol, swapFrame) {
  325.     if (!fileName) return;
  326.     /* See if we already precached this one. */
  327.     for (j=0; j<filesToPreload.length; j++) {
  328.         if (filesToPreload[j] == fileName) {
  329.             return;
  330.         }
  331.     }
  332.     filesToPreload[j] = fileName;
  333.             
  334.     // Declare and name each image and specify width and height. Ex: I_02_02_f2= new Image(47, 16);
  335.     allThePreloads += ("  " + cellName + "_f" + (swapFrame+1) + 
  336.         " = new Image(" + swapTable[swapRow][swapCol].width + " ,"  + swapTable[swapRow][swapCol].height +"); ");
  337.     // Write image source. Ex: I_02_02_f2.src = "File_02_02_f2.gif";
  338.     allThePreloads += (cellName + "_f" + (swapFrame+1) + 
  339.         ".src = \"" + fileName +"\";\n");
  340. }
  341.  
  342. function DoPreload(curBeh) {
  343.     var swapRow = curBeh.targetRowNum;
  344.     var swapCol = curBeh.targetColumnNum;
  345.     var swapFrame = curBeh.targetFrameNum; 
  346.     var swapTable = curBeh.targetTable;
  347.     var fileName;
  348.     var curFile;
  349.     var j;
  350.     cellName = CellName(swapTable, swapRow,swapCol);
  351.     if (!swapTable) {
  352.         return;
  353.     }
  354.     if (curBeh.hasHref) {
  355.         fileName = curBeh.href;
  356.         swapFrame = autoFrame;
  357.         autoFrame++;
  358.     } else {
  359.         curFile = swapTable[swapRow][swapCol].getFrameFileName(swapFrame);
  360.         if (curFile) 
  361.             fileName = swapTable.imagesDirPath + curFile + swapTable[swapRow][swapCol].imageSuffix;
  362.     }
  363.     PreloadFile(fileName, swapTable, swapRow, swapCol, swapFrame);
  364.     if (curBeh.downHighlight) {
  365.         if (curBeh.hasDhHref) {
  366.             fileName = curBeh.dhHref;
  367.         } else {
  368.             var f = curBeh.dhTargetFrameNum;
  369.             curFile = swapTable[swapRow][swapCol].getFrameFileName(f);
  370.             if (curFile) { 
  371.                 fileName = swapTable.imagesDirPath + curFile + swapTable[swapRow][swapCol].imageSuffix;
  372.             }
  373.         }
  374.         if (fileName) {
  375.             PreloadFile(fileName, swapTable, swapRow, swapCol, swapFrame);
  376.         }
  377.     }
  378.     /* Preload frame 0. */
  379.     curFile = swapTable[swapRow][swapCol].getFrameFileName(0);
  380.     if (curFile) 
  381.         fileName = swapTable.imagesDirPath + curFile + swapTable[swapRow][swapCol].imageSuffix;
  382.     if (fileName) {
  383.         PreloadFile(fileName, swapTable, swapRow, swapCol, 0);
  384.     }
  385. }
  386.  
  387. // Examine all behaviors to determine what actions are present. 
  388. // Determine which files to pre-cache.
  389. var FWLoadInit = "\n function FWLoadInit() {\n";
  390.  
  391. function DoFileAndPreloads(curSlices) {
  392.     for (var curRow = 0; curRow < curSlices.numRows; curRow++) {
  393.         for (var curCol = 0; curCol < curSlices.numColumns; curCol++) {
  394.             if (curSlices[curRow][curCol].skipCell) continue;
  395.             var nestedTable = curSlices[curRow][curCol].nestedTableSlices;
  396.             if (nestedTable) {
  397.                 DoFileAndPreloads(nestedTable);
  398.                 continue;
  399.             }
  400.             if (curSlices[curRow][curCol].behaviors.numberOfBehaviors > 0) {
  401.                 var behaviors = curSlices[curRow][curCol].behaviors;
  402.                 for (var i=0; i<behaviors.numberOfBehaviors; i++) {
  403.                     var curBehavior = behaviors[i];
  404.                     if (curBehavior.action == kActionSwapImage) {
  405.                         DoFile(curBehavior);
  406.                         hasSwap = true;
  407.                     }
  408.                     if (curBehavior.action == kActionButtonDown || curBehavior.action == kActionButtonHighlight) {
  409.                         DoFile(curBehavior);
  410.                         hasDown = true;
  411.                     }
  412.                     if (curBehavior.action == kActionSwapImageRestore) {
  413.                         hasRestore = true;
  414.                     }
  415.                     if (curBehavior.action == kActionStatusMessage) {
  416.                         hasStatusMessage = true;
  417.                     }
  418.                 }
  419.                 var init = ProcessEvent(behaviors, kEventOnLoad);
  420.                 if (init != "") {
  421.                     hasOnloadInits = true;    
  422.                     FWLoadInit += init + "\n";
  423.                 }
  424.             }
  425.             var imagemap = curSlices[curRow][curCol].imagemap;
  426.             for (var j=0; j < imagemap.numberOfURLs; j++) {
  427.                 var curImagemap = imagemap[j];
  428.                 var behaviors = curImagemap.behaviors;
  429.                 for (var i=0; i<behaviors.numberOfBehaviors; i++) {
  430.                     var curBehavior = behaviors[i];
  431.                     if (curBehavior.action == kActionSwapImage) {
  432.                         DoFile(curBehavior);
  433.                         hasSwap = true;
  434.                     }
  435.                     if (curBehavior.action == kActionButtonDown || curBehavior.action == kActionButtonHighlight) {
  436.                         DoFile(curBehavior);
  437.                         hasDown = true;
  438.                     }
  439.                     if (curBehavior.action == kActionSwapImageRestore) {
  440.                         hasRestore = true;
  441.                     }
  442.                     if (curBehavior.action == kActionStatusMessage) {
  443.                         hasStatusMessage = true;
  444.                     }
  445.                 }
  446.                 var init = ProcessEvent(behaviors, kEventOnLoad) ;
  447.                 if (init != "") {
  448.                     hasOnloadInits = true;    
  449.                     FWLoadInit += init + "\n";
  450.                 }
  451.             }
  452.         }
  453.     }
  454. }
  455.  
  456.  
  457. var wroteJsHeader = false;
  458. function WriteJsHeader()
  459. {
  460.     if (wroteJsHeader) return;
  461.     wroteJsHeader = true;
  462.     if (doHeader) {
  463.         // Write comment for start of JavaScript copy/paste section.
  464.         WRITE_HTML_COMMENT("------------------ BEGIN COPYING THE JAVASCRIPT SECTION HERE -----------------");
  465.     }
  466.  
  467.     // Begin Script. Hide Script from non-javascript-enabled browsers.
  468.     WRITE_HTML("<script language=\"JavaScript\">\n");
  469.     WRITE_HTML("<!-- hide this script from non-javascript-enabled browsers\n");
  470. }
  471.  
  472. // Find and declare all images used in Behaviors.
  473.  
  474. var allThePreloads = "";
  475.  
  476. DoFileAndPreloads(slices);
  477.     
  478. WRITE_HTML("\n");
  479.  
  480. /*--------------------------  JavaScript functions used in the HTML -----------------*/
  481.  
  482. // Write out only the JavaScript functions needed for the HTM
  483.  
  484. // Write function dm if document includes status bar messages.
  485. if (hasStatusMessage) {
  486.     WriteJsHeader();
  487.     WRITE_JS_COMMENT("Function that displays status bar messages.")
  488.     //WRITE_HTML(MM_displayStatusMsg);
  489.     WRITE_HTML("function MM_displayStatusMsg(msgStr)  { //v3.0\n");
  490.     WRITE_HTML("    status=msgStr; document.MM_returnValue = true;\n");
  491.     WRITE_HTML("}\n");
  492.     WRITE_HTML("\n");
  493. }
  494.  
  495. if (hasSwap || hasDown) {
  496.     WriteJsHeader();
  497.         //WRITE_HTML(MM_findObj);
  498.         WRITE_HTML("function MM_findObj(n, d) { //v3.0\n");
  499.         WRITE_HTML("  var p,i,x;  if(!d) d=document; if((p=n.indexOf(\"?\"))>0&&parent.frames.length) {\n");
  500.         WRITE_HTML("    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}\n");
  501.         WRITE_HTML("  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];\n");
  502.         WRITE_HTML("  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;\n");
  503.         WRITE_HTML("}\n");
  504.     WRITE_HTML("\n");
  505. }
  506.  
  507. // Write function di20 if document includes swap image behaviors.
  508. if (hasSwap) {
  509.     WriteJsHeader();
  510.     WRITE_JS_COMMENT("Functions that swaps images.")
  511.     //WRITE_HTML(MM_swapImage);
  512.     WRITE_HTML("function MM_swapImage() { //v3.0\n");
  513.     WRITE_HTML("  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)\n");
  514.     WRITE_HTML("   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}\n");
  515.     WRITE_HTML("}\n");
  516.  
  517. }
  518.  
  519. // Write function di20 if document includes swap image behaviors.
  520. if (hasDown) {
  521.     WriteJsHeader();
  522.     WRITE_JS_COMMENT("Functions that swaps down images.")
  523.     //WRITE_HTML(MM_nbGroup);
  524.     WRITE_HTML("function MM_nbGroup(event, grpName) { //v3.0\n");
  525.     WRITE_HTML("  var i,img,nbArr,args=MM_nbGroup.arguments;\n");
  526.     WRITE_HTML("  if (event == \"init\" && args.length > 2) {\n");
  527.     WRITE_HTML("    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {\n");
  528.     WRITE_HTML("      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;\n");
  529.     WRITE_HTML("      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();\n");
  530.     WRITE_HTML("      nbArr[nbArr.length] = img;\n");
  531.     WRITE_HTML("      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {\n");
  532.     WRITE_HTML("        if (!img.MM_up) img.MM_up = img.src;\n");
  533.     WRITE_HTML("        img.src = img.MM_dn = args[i+1];\n");
  534.     WRITE_HTML("        nbArr[nbArr.length] = img;\n");
  535.     WRITE_HTML("    } }\n");
  536.     WRITE_HTML("  } else if (event == \"over\") {\n");
  537.     WRITE_HTML("    document.MM_nbOver = nbArr = new Array();\n");
  538.     WRITE_HTML("    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {\n");
  539.     WRITE_HTML("      if (!img.MM_up) img.MM_up = img.src;\n");
  540.     WRITE_HTML("      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : args[i+1];\n");
  541.     WRITE_HTML("      nbArr[nbArr.length] = img;\n");
  542.     WRITE_HTML("    }\n");
  543.     WRITE_HTML("  } else if (event == \"out\" ) {\n");
  544.     WRITE_HTML("    for (i=0; i < document.MM_nbOver.length; i++) {\n");
  545.     WRITE_HTML("      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }\n");
  546.     WRITE_HTML("  } else if (event == \"down\") {\n");
  547.     WRITE_HTML("    if ((nbArr = document[grpName]) != null)\n");
  548.     WRITE_HTML("      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }\n");
  549.     WRITE_HTML("    document[grpName] = nbArr = new Array();\n");
  550.     WRITE_HTML("    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {\n");
  551.     WRITE_HTML("      if (!img.MM_up) img.MM_up = img.src;\n");
  552.     WRITE_HTML("      img.src = img.MM_dn = args[i+1];\n");
  553.     WRITE_HTML("      nbArr[nbArr.length] = img;\n");
  554.     WRITE_HTML("  } }\n");
  555.     WRITE_HTML("}\n");
  556.     WRITE_HTML("\n");
  557. }
  558.  
  559. if (hasRestore) {
  560.     WriteJsHeader();
  561.     //WRITE_HTML(MM_swapImgRestore);    
  562.     WRITE_HTML("function MM_swapImgRestore() { //v3.0\n");
  563.     WRITE_HTML("  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;\n");
  564.     WRITE_HTML("}\n");
  565.     WRITE_HTML("\n");
  566. }
  567.  
  568. // Functions that hook the onload event.
  569. function FWOnLoad() {
  570.     if (FwPrevHook) FwPrevHook();
  571.     FWLoadInit();
  572. }
  573.  
  574. function FWHookLoad()
  575. {
  576.     var agent = navigator.userAgent;
  577.     var hookPrev = true;
  578.     if (agent.indexOf("MSIE") != -1 && 
  579.         agent.indexOf("Mac_") != -1) {
  580.         hookPrev = false;
  581.     } 
  582.     if (hookPrev) {
  583.         FwPrevHook = window.onload;
  584.     } else {
  585.         FwPrevHook = false;
  586.     }
  587.     window.onload = FWOnLoad;
  588. }
  589.  
  590. if ( hasOnloadInits) {
  591.     WriteJsHeader();
  592.     WRITE_HTML(FWOnLoad);
  593.     WRITE_HTML(FWHookLoad);
  594. }
  595.  
  596. if (wroteJsHeader) {
  597.     // Stop hiding script from non-javascript-enabled browsers. End script.
  598.     WRITE_HTML("// stop hiding -->\n");
  599.     WRITE_HTML("</script>\n");
  600.     if (doHeader) {
  601.         // End JavaScript copy/paste section.
  602.         WRITE_HTML_COMMENT("------------------------ STOP COPYING THE JAVASCRIPT HERE ------------------------");
  603.     }
  604. }
  605. /*----------------- END JavaScript functions used in the HTML -----------------*/
  606.  
  607. if (doHeader) {
  608.     // Close head tag.
  609.     WRITE_HTML("</head>\n");
  610.  
  611.     // Begin body tag. Set background color to Fireworks document canvas color.
  612.     WRITE_HTML("<body bgcolor=\"#", exportDoc.backgroundColor.toString(16), "\" onload=\"\"" );
  613.  
  614.     WRITE_HTML( ">\n");
  615.     WRITE_HTML("\n");
  616. }
  617.  
  618. // Write comment for start of table copy/paste section.
  619. WRITE_HTML_COMMENT("The following section is an image or HTML table which reassembles the sliced image in a browser.");
  620. WRITE_HTML_COMMENT("Copy the table section including the opening and closing table tags, and paste the data where");
  621. WRITE_HTML_COMMENT("you want the reassembled image to appear in the destination document. ");
  622. WRITE_HTML("\n");
  623. WRITE_HTML_COMMENT("------------------------ BEGIN COPYING THE HTML --------------------------");
  624. WRITE_HTML("\n");
  625.  
  626.  
  627. function WriteTable(curSlices, indent) {
  628.         // Begin table.
  629.     var needTable = curSlices.numRows > 1 || curSlices.numColumns > 1;
  630.     var curCol;
  631.     var curRow;
  632.     var downIndex = 0;
  633.  
  634.     if (needTable) {
  635.         WRITE_HTML("<table ");
  636.  
  637.         // If the Fireworks document's canvas is not transparent and the Include undefined curSlices checkbox
  638.         // is off, give the table a background color based on the Fireworks document's canvas color.
  639.         if (!exportDoc.backgroundIsTransparent && curSlices.doSkipUndefined) {
  640.             WRITE_HTML("bgcolor=\"#", exportDoc.backgroundColor, "\" ");
  641.         } 
  642.         WRITE_HTML("border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"",
  643.                 curSlices.width, "\">\n");
  644.  
  645.         /* This is the magic comment for html update. */
  646.         if (indent == "") {
  647.             //<--- fwtable fwsrc="mydoc" fwbase="basename" --->
  648.             var comment = "<!-- fwtable fwsrc=\"" + exportDoc.docSaveName + "\" fwbase=\"" + exportDoc.filename + "\"" + " -->\n";
  649.             WRITE_HTML(comment);
  650.             if (allThePreloads != "" || hasOnloadInits) {
  651.                 WRITE_HTML("  <script language=\"JavaScript\">\n");
  652.                 WRITE_HTML("  <!-- hide \n");
  653.                 if ( hasOnloadInits) {
  654.                     WRITE_HTML("  " + FWLoadInit + "}\n");
  655.                     WRITE_HTML("  var FwPrevHook = false;\n");
  656.                     WRITE_HTML("  if (FWHookLoad) {FWHookLoad(); FWHookLoad=false;}\n");
  657.                 }
  658.                 if (allThePreloads != "") {
  659.                     WRITE_HTML("  if (document.images) {\n");
  660.                     WRITE_HTML(allThePreloads);
  661.                     WRITE_HTML("  }\n");
  662.                 }
  663.                 WRITE_HTML("  // stop hiding -->\n");
  664.                 WRITE_HTML("  </script>\n");
  665.             }
  666.         }
  667.  
  668.     
  669.         // If shims have been specified, write shim row.    
  670.         if (curSlices.doShimEdges) {
  671.             WRITE_HTML(indent+"  <tr>\n");
  672.             WRITE_HTML_COMMENT(" Shim row, height 1. ");
  673.             for (curCol = 0; curCol < curSlices.numColumns; curCol++) {
  674.                 WRITE_HTML(indent+"   <td><img src=\"", curSlices.shimPath, "\" width=\"", 
  675.                     curSlices[0][curCol].cellWidth, "\" height=\"1\" border=\"0\"></td>\n"); 
  676.             }
  677.             WRITE_HTML(indent+"   <td><img src=\"", curSlices.shimPath, "\" width=\"1", 
  678.                 "\" height=\"1\" border=\"0\"></td>\n"); 
  679.             WRITE_HTML(indent+"  </tr>\n");
  680.             WRITE_HTML("\n");
  681.         }
  682.     }
  683.  
  684.     // Write table rows.
  685.     for (curRow = 0; curRow < curSlices.numRows; curRow++) {
  686.         if (needTable) {
  687.             WRITE_HTML(indent+"  <tr valign=\"top\">");
  688.             WRITE_HTML_COMMENT(" row "+(curRow+1)+" ");
  689.             if (!doComments) WRITE_HTML("\n");
  690.         }
  691.         for (curCol = 0; curCol < curSlices.numColumns; curCol++) {
  692.             var curSlice = curSlices[curRow][curCol];
  693.             if (curSlice.skipCell) continue; 
  694.  
  695.             if (needTable) {
  696.                 // Write rowspan and colspan if necessary. Ex: rowspan="1" colspan="3"
  697.                 WRITE_HTML(indent+"   <td");
  698.                 if (curSlice.rowSpan > 1) {
  699.                     WRITE_HTML(" rowspan=\"", curSlice.rowSpan,"\"");
  700.                 }
  701.                 if (curSlice.columnSpan>1) {
  702.                     WRITE_HTML(" colspan=\"", curSlice.columnSpan, "\"");
  703.                 }
  704.                 WRITE_HTML(">");
  705.             }
  706.  
  707.             var nestedTable = curSlice.nestedTableSlices;
  708.             if (nestedTable) {
  709.                 WriteTable(nestedTable, "    "+indent);
  710.                 if (needTable) {
  711.                     WRITE_HTML("</td>");
  712.                 }
  713.                 WRITE_HTML("\n");
  714.                 continue;
  715.             }
  716.  
  717.             // Write HTML text from curSlices set to "Text (No Image)"
  718.             if (!curSlice.hasImage) {
  719.                 // no image, just dump out html text.
  720.                 if (curSlice.htmlText) {
  721.                     WRITE_HTML(curSlice.htmlText);
  722.                 } else if (needTable) {
  723.                     if (curSlices.shimPath) {
  724.                         WRITE_HTML("<img src=\"",
  725.                             curSlices.shimPath, "\" width=\"", curSlice.width, "\" height=\"", 
  726.                             curSlice.height, "\" border=\"0\">"); 
  727.                     }
  728.                 }
  729.                 if (needTable) WRITE_HTML("</td>\n");
  730.                 continue;
  731.             }
  732.  
  733.             // If current slice is not defined by a slice object and Export Undefined
  734.             // curSlices is not checked, don't output an image and if Shims are specified 
  735.             // place a shim image in the current cel
  736.             if (curSlice.isUndefined && curSlices.doSkipUndefined) {
  737.                 if (needTable) {
  738.                     if (curSlices.shimPath) {
  739.                         WRITE_HTML("<img src=\"",
  740.                             curSlices.shimPath, "\" width=\"", curSlice.width, "\" height=\"", 
  741.                             curSlice.height, "\" border=\"0\">"); 
  742.                     }
  743.                     WRITE_HTML("</td>\n");
  744.                 }
  745.                 // Tell Fireworks to not write the image file. Setting the filename to "" forces 
  746.                 // Fireworks to not generate the image.
  747.                 var q;
  748.                 for (q=0; q<exportDoc.numFrames; q++) {
  749.                     curSlice.setFrameFileName(q, "");
  750.                 }    
  751.                 continue;
  752.             }
  753.  
  754.             // Write link if slice has URL attached.
  755.             var href = "href=\"#\"";
  756.             var hasHref = curSlice.hasHref;
  757.             var abortHref = false;
  758.             if (curSlice.hasHref) {
  759.                 href = "href=\"";
  760.                 href += curSlice.href;
  761.                 href += "\"";
  762.                 if (curSlice.hasTargetText) {
  763.                     href += " target=\"";
  764.                     href += curSlice.targetText;
  765.                     href += "\"";
  766.                 }
  767.                 
  768.             } else {
  769.                 var link = "";
  770.                 if (exportDoc.backgroundLink) {
  771.                     link = exportDoc.backgroundLink.href;
  772.                 }
  773.                 if (link != "") {
  774.                     hasHref = true;
  775.                     href = "href=\"" + link +"\"";
  776.                 }
  777.             }
  778.  
  779.             if (slices.doDemoHTML && curSlice.downIndex>0) {
  780.                 href = "href=\"" + slices.demoHref(curSlice.downIndex) +".htm\"";
  781.             }
  782.  
  783.             cellName = CellName(curSlices, curRow, curCol);
  784.             var anchorTagOpen = false;
  785.  
  786.             // If the slice has image map hotspots and has a url attached to it,
  787.             // ignore the url here and move it into the image map.
  788.             if (curSlice.hasImage && curSlice.hasImagemap) {
  789.                 abortHref = true;  // we will put the href in the imagemaps.
  790.             }
  791.  
  792.             // Write rollover and swap image events.
  793.             if (!abortHref) {
  794.                 var behaviors = curSlice.behaviors;
  795.                 var gotJavascript = ProcessBehavior(behaviors);
  796.  
  797.                 if ( gotJavascript || hasHref) {
  798.                       WRITE_HTML("<a ");
  799.                     anchorTagOpen = true;
  800.                     WRITE_HTML(href);
  801.  
  802.                     if (javaOut != "") {
  803.                         WRITE_HTML(" onMouseOut=\"", javaOut, "\" ");
  804.                     }
  805.                     if (javaOver != "") {
  806.                         WRITE_HTML(" onMouseOver=\"", javaOver, "\" ");
  807.                     }
  808.                     if (javaClick != "") {
  809.                         WRITE_HTML(" onClick=\"", javaClick, "\" ");
  810.                     }
  811.                     WRITE_HTML(">");
  812.                 }
  813.             }
  814.  
  815.             // Place image.
  816.             if (curSlice.hasImage) {
  817.                 var imageName = curSlice.getFrameFileName(0); 
  818.                 if (slices.doDemoHTML && slices.demoIndex>0 && 
  819.                     slices.demoIndex == curSlice.downIndex) {
  820.                     imageName = curSlice.getFrameFileName(2);
  821.                 } 
  822.                 var altText = "";
  823.                 if (curSlice.hasAltText) {
  824.                     altText = curSlice.altText;
  825.                 } else {
  826.                     altText = exportDoc.altText;
  827.                 }
  828.                 
  829.                 // Assemble info for image tag.
  830.                 // Ex: <img name="n_03_02" src="File_03_02.gif" width="79" height="71" border="0"
  831.                 WRITE_HTML("<img name=\"", cellName, "\" src=\"",
  832.                     curSlices.imagesDirPath, imageName, curSlice.imageSuffix, "\" width=\"",
  833.                     curSlice.width,"\" height=\"", curSlice.height, "\" border=\"0\"");
  834.                 
  835.                 // Write image map name.
  836.                 // Ex: usemap="#base_r1_c2"
  837.                 if (curSlice.hasImagemap) {     
  838.                     WRITE_HTML(" usemap=\"#m_", imageName, "\""); 
  839.                 }
  840.                 
  841.                 // Write alt text.
  842.                 if (altText != "") {
  843.                     WRITE_HTML(" alt=\"", altText, "\"");
  844.                 }
  845.                 WRITE_HTML(">");    
  846.             }
  847.  
  848.             if (anchorTagOpen) {
  849.                 WRITE_HTML("</a>");    
  850.             }
  851.             if (needTable) WRITE_HTML("</td>\n");    
  852.         }
  853.         
  854.         if (needTable) {
  855.             // Place shim in rightmost column of table.
  856.             if (curSlices.doShimEdges) {
  857.                 /* Write the 1 pixel transparent shim. */
  858.                 WRITE_HTML("   <td><img src=\"",
  859.                     curSlices.shimPath, "\" width=\"1\" height=\"", 
  860.                     curSlices[curRow][0].cellHeight, "\" border=\"0\"></td>\n"); 
  861.             }
  862.             WRITE_HTML(indent+"  </tr>\n");
  863.         }
  864.     }        
  865.  
  866.     if (needTable) {
  867.         // Close table.
  868.         if (indent != "") WRITE_HTML(indent+"</table>");
  869.     }
  870. }
  871.  
  872. function WriteImagemaps(curSlices, indent) {
  873.     // Traverse all curSlices and generate any image maps needed.
  874.     if (!indentNestedImagemaps) indent="";
  875.     for (var curRow = 0; curRow < curSlices.numRows; curRow++) {
  876.         for (var curCol = 0; curCol < curSlices.numColumns; curCol++) {
  877.             var curSlice = curSlices[curRow][curCol];
  878.             if (curSlice.skipCell) continue; 
  879.             var nestedTable = curSlice.nestedTableSlices;
  880.             if (nestedTable) {
  881.                 WriteImagemaps(nestedTable, "    "+indent);
  882.                 continue;
  883.             }
  884.             if (curSlice.hasImagemap) {
  885.                 
  886.                 // Write the image map.
  887.                 WRITE_HTML(indent+"<map name=\"m_", curSlice.getFrameFileName(0), "\">\n");
  888.  
  889.                 var i = 0;
  890.                 var imagemap = curSlice.imagemap;
  891.                 while (i < imagemap.numberOfURLs) {
  892.                     var curImagemap = imagemap[i];
  893.  
  894.                     var behaviors = curImagemap.behaviors;
  895.  
  896.                     if (behaviors.numberOfBehaviors==0) {
  897.                         var behaviors = curSlice.behaviors;
  898.                     }
  899.                      javaOver = "";
  900.                     javaOut = "";
  901.                     javaClick = "";
  902.                     var gotJavascript = ProcessBehavior(behaviors);
  903.     
  904.                     // Write the area tag with shape definitions.
  905.                     WRITE_HTML(indent+"<area shape=\"");
  906.                     WRITE_HTML(curImagemap.shape); // Shapes are rect poly and circle
  907.                     WRITE_HTML("\" coords=\"");
  908.                     for (var j=0; j<curImagemap.numCoords; j++) {
  909.                         if (j>0) WRITE_HTML(",");
  910.                         // polygon has n coords.
  911.                         // rect has 2 coords, topLeft, and botomRight.
  912.                         // circle has one coord, center; plus radius.
  913.                         WRITE_HTML((curImagemap.xCoord(j)-curSlice.left), ",", (curImagemap.yCoord(j)-curSlice.top)); 
  914.                     }
  915.                     if (curImagemap.shape == "circle") {
  916.                         // Write the radius for circle hotspots.
  917.                         WRITE_HTML(", ", curImagemap.radius);
  918.                     }
  919.                     WRITE_HTML("\"");
  920.                     var href = " href=\"#\"";
  921.                     if (curImagemap.hasHref) {
  922.                         href = " href=\"";
  923.                         href += curImagemap.href;
  924.                         href += "\"";
  925.                         if (curImagemap.hasTargetText) {
  926.                             href += " target=\"";
  927.                             href += curImagemap.targetText;
  928.                             href += "\"";
  929.                         }
  930.                     }
  931.  
  932.                     WRITE_HTML(href);
  933.                     
  934.                     // Write alt text for hotspot.
  935.                     var altText = "";
  936.                     if (curImagemap.hasAltText) {
  937.                         altText = curImagemap.altText;
  938.                     } else {
  939.                         altText = exportDoc.altText;
  940.                     }
  941.  
  942.                     if (altText!="") {
  943.                         WRITE_HTML(" title=\"", altText, "\"");
  944.                         WRITE_HTML(" alt=\"", altText, "\"");
  945.                     }
  946.  
  947.                     // Write rollover and swap image behaviors.
  948.                     if (javaOut != "") {
  949.                         WRITE_HTML(" onMouseOut=\"", javaOut, "\" ");
  950.                     }
  951.                     if (javaOver != "") {
  952.                         WRITE_HTML(" onMouseOver=\"", javaOver, "\" ");
  953.                     }
  954.                     if (javaClick != "") {
  955.                         WRITE_HTML(" onClick=\"", javaClick, "\" ");
  956.                     }
  957.  
  958.                     WRITE_HTML(" >\n");
  959.                     i++;
  960.                 } 
  961.                 var behaviors = curSlices[curRow][curCol].behaviors;
  962.                  javaOver = "";
  963.                 javaOut = "";
  964.                 javaClick = "";
  965.                 var gotJavascript = ProcessBehavior(behaviors);
  966.                 
  967.                 var link = "";
  968.                 if (curSlice.hasHref) {
  969.                     link = curSlice.href;
  970.                 } else {  
  971.                     if (exportDoc.backgroundLink) {
  972.                         link = exportDoc.backgroundLink.href;
  973.                     }
  974.                 }
  975.  
  976.                 // If the current slice had a URL attached, it was moved and written here.
  977.                 if (gotJavascript || link != "") {
  978.                     WRITE_HTML(indent+"<area shape=\"rect\" coords=\"0,0, ", curSlice.width, ",", curSlice.height, "\" ");
  979.                     var href="#";
  980.                     if (link!="") {
  981.                         href = link;
  982.                     }
  983.                     WRITE_HTML("href=\"", href, "\"");
  984.  
  985.                     if (curSlice.hasTargetText) {
  986.                         WRITE_HTML("\n  target=\"", curSlices[curRow][curCol].targetText, "\"");
  987.                     }
  988.                     if (javaOut != "") {
  989.                         WRITE_HTML(" onMouseOut=\"", javaOut, "\" ");
  990.                     }
  991.                     if (javaOver != "") {
  992.                         WRITE_HTML(" onMouseOver=\"", javaOver, "\" ");
  993.                     }
  994.                     if (javaClick != "") {
  995.                         WRITE_HTML(" onClick=\"", javaClick, "\" ");
  996.                     }
  997.                     var altText = "";
  998.                     if (curSlice.hasAltText) {
  999.                         altText = curSlice.altText;
  1000.                     } else {
  1001.                         altText = exportDoc.altText;
  1002.                     }
  1003.                     if (altText!="") {
  1004.                         WRITE_HTML(" title=\"", altText, "\"");
  1005.                         WRITE_HTML(" alt=\"", altText, "\"");
  1006.                     }
  1007.                     WRITE_HTML(">\n");
  1008.                 }    
  1009.  
  1010.                 WRITE_HTML(indent+"</map>\n")
  1011.                 WRITE_HTML("\n");
  1012.             }
  1013.         }
  1014.     }
  1015. }
  1016.  
  1017. WriteTable(slices, "");
  1018. WRITE_HTML("\n");
  1019. WriteImagemaps(slices, "");
  1020.  
  1021. // End table copy/paste section.
  1022. WRITE_HTML_COMMENT("   This HTML was automatically created with Macromedia Fireworks 3.0   ");
  1023. WRITE_HTML_COMMENT("   http://www.macromedia.com   ");
  1024. WRITE_HTML("\n");
  1025. var needTable = slices.numRows > 1 || slices.numColumns > 1;
  1026. if (needTable) {
  1027.     WRITE_HTML("</table>\n");
  1028. }
  1029.  
  1030. WRITE_HTML_COMMENT("------------------------- STOP COPYING THE HTML HERE -------------------------");
  1031.  
  1032. WRITE_HTML("\n");  
  1033.  
  1034. if (doHeader) {
  1035.     WRITE_HTML("</body>\n");
  1036.  
  1037.     WRITE_HTML("\n");
  1038.     WRITE_HTML("</html>\n");
  1039.     WRITE_HTML("\n");
  1040. }
  1041.  
  1042.  
  1043.